package com.ruoyi.qualityManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qualityManagement.domain.IncomingInspection;
import com.ruoyi.qualityManagement.service.IIncomingInspectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 来料检管理Controller
 * 
 * @author admin
 * @date 2024-07-05
 */
@RestController
@RequestMapping("/qualityManagement/incomingInspection")
public class IncomingInspectionController extends BaseController
{
    @Autowired
    private IIncomingInspectionService incomingInspectionService;

    /**
     * 查询来料检管理列表
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:incomingInspection:list')")
    @GetMapping("/list")
    public TableDataInfo list(IncomingInspection incomingInspection)
    {
        startPage();
        List<IncomingInspection> list = incomingInspectionService.selectIncomingInspectionList(incomingInspection);
        return getDataTable(list);
    }

    /**
     * 导出来料检管理列表
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:incomingInspection:export')")
    @Log(title = "来料检管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IncomingInspection incomingInspection)
    {
        List<IncomingInspection> list = incomingInspectionService.selectIncomingInspectionList(incomingInspection);
        ExcelUtil<IncomingInspection> util = new ExcelUtil<IncomingInspection>(IncomingInspection.class);
        util.exportExcel(response, list, "来料检管理数据");
    }

    /**
     * 获取来料检管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:incomingInspection:query')")
    @GetMapping(value = "/{inspectionId}")
    public AjaxResult getInfo(@PathVariable("inspectionId") Long inspectionId)
    {
        return success(incomingInspectionService.selectIncomingInspectionByInspectionId(inspectionId));
    }

    /**
     * 新增来料检管理
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:incomingInspection:add')")
    @Log(title = "来料检管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IncomingInspection incomingInspection)
    {
        return toAjax(incomingInspectionService.insertIncomingInspection(incomingInspection));
    }

    /**
     * 修改来料检管理
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:incomingInspection:edit')")
    @Log(title = "来料检管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IncomingInspection incomingInspection)
    {
        return toAjax(incomingInspectionService.updateIncomingInspection(incomingInspection));
    }

    /**
     * 删除来料检管理
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:incomingInspection:remove')")
    @Log(title = "来料检管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inspectionIds}")
    public AjaxResult remove(@PathVariable Long[] inspectionIds)
    {
        return toAjax(incomingInspectionService.deleteIncomingInspectionByInspectionIds(inspectionIds));
    }
}
